var refreshEpgTimer = null;
var refreshEpgTime = 30*1000;
var refreshEpgIntervalTime = 10*60*1000;
var refreshEpgStartTime = 0;

var EPG_URL = 'http://114.142.153.146:8080/ad/epg.js';
function refreshEpg(){
	refreshEpgTimer = setInterval("refreshEpgInterface()",refreshEpgTime);
}

function refreshEpgInterface(){
	var date = new Date();
	var t = date.getTime();
	if(t - refreshEpgStartTime >= refreshEpgIntervalTime){
		refreshEpgIntervalTime = t;
		programListener();
	}	
}

function programListener(){
	
	$.ajax({
		url:EPG_URL,
		success:function(data){
			eval("var epgList = " + data);
			if(epgList){
				for(var i = 0;i<epgList.length;i++){
					var rel = epgList[i];
					var id = rel.channelId; 
					setSession('p_'+id,rel.toJSON());
				}
			}
		},error:function(e){
			alert("Run programListener error....");
		}
	});
}


